package daos

import model.Pais
import org.junit.Before
import org.junit.Test

import static org.junit.Assert.*
import static org.mockito.Mockito.*

class MapaMundiTest {
	
	var MapaMundi mapaMundiTest
	var Pais mockPais
	
	@Before
	def void setUp(){
		this.mapaMundiTest = new MapaMundi()
		this.mockPais = mock(typeof(Pais))
		when(this.mockPais.nombre).thenReturn("Argentina")
	}
	
	@Test
	def agregarPaisTest(){
		this.mapaMundiTest.agregar(this.mockPais)
		assertEquals("Deberia tener un pais", this.mapaMundiTest.buscar(this.mockPais.nombre).nombre, this.mockPais.nombre)
	}
	
	@Test(expected = RuntimeException)
	def void agregarPaisRepetido(){
		this.mapaMundiTest.agregar(this.mockPais)
		this.mapaMundiTest.agregar(this.mockPais)
	}
	
	@Test(expected = RuntimeException)
	def void quitarPais(){
		this.mapaMundiTest.quitar(this.mockPais)
		this.mapaMundiTest.buscar(this.mockPais.nombre)
		
	}
}